package model.conditions;

import metier.GameState;
import metier.Objet;

public class PositionCondition extends Condition {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5856119511113748727L;
	protected Integer column;
	protected Integer row;
	
	public PositionCondition() {
		super();
	}
	
	public PositionCondition(Integer column, Integer row) {
		super();
		this.column = column;
		this.row = row;
	}

	public Integer getColumn() {
		return column;
	}

	public void setColumn(Integer column) {
		this.column = column;
	}

	public Integer getRow() {
		return row;
	}

	public void setRow(Integer row) {
		this.row = row;
	}

	@Override
	public boolean verify(GameState state, Objet sender) {
		boolean res = false;
		int c = sender.getPosition().getColumn().intValue();
		int r = sender.getPosition().getRow().intValue();
		if(column!=null && row!=null && c == column.intValue() && r == row.intValue()) {
			res = true;
		}
		
		if(column==null && row!=null && r == row.intValue()) {
			res = true;
		}
		
		if(row==null && column!=null && c == column.intValue()) {
			res = true;
		}
		
		if(!inverse) {
			return res;
		} else {
			return !res;
		}
	}

}
